﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Runtime.Serialization;

namespace PMisuseAn.io
{
    [Serializable()]
    class HistoryItem : ISerializable
    {
        public DateTime timestamp;
        public ListDictionary interactionHistoryItem;
        public string clusterName;

        //Default constructor
        public HistoryItem(ListDictionary interactionHistoryItem_)
        {
            timestamp = DateTime.Now;
            interactionHistoryItem = interactionHistoryItem_;
            clusterName = MainWindow.clusterName;
        }

        //Deserialization constructor.
        public HistoryItem(SerializationInfo info, StreamingContext ctxt)
        {
            //Get the values from info and assign them to the appropriate properties
            clusterName = (string)info.GetValue("projectClusterName", typeof(string));
            timestamp = (DateTime)info.GetValue("timeStamp", typeof(DateTime));
            interactionHistoryItem = (ListDictionary)info.GetValue("interactionItem", typeof(ListDictionary));
        }
        
        //Serialization function.
        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("projectClusterName", clusterName);
            info.AddValue("timeStamp", timestamp);
            info.AddValue("interactionItem", interactionHistoryItem);
        }

    }
}
